package com.tpyule.tpclass.service.impl;

import com.tpyule.tpclass.dao.FavoriteDao;
import com.tpyule.tpclass.entity.bo.FCDetailBo;
import com.tpyule.tpclass.entity.dto.FavoriteDto;
import com.tpyule.tpclass.entity.pojo.Favorite;
import com.tpyule.tpclass.service.FavoriteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * @author zzz
 * @version 1.0
 * @date 2020/4/25 14:16
 */
@Service
public class FavoriteServiceImpl implements FavoriteService {
    @Autowired
    FavoriteDao favoriteDao;
    @Override
    public int addFavorite(Favorite favorite) {
        favorite.setId(UUID.randomUUID().toString().toUpperCase());
        return favoriteDao.addFavorite(favorite);
    }

    @Override
    public int deleteFavorite(Favorite favorite) {
        return favoriteDao.deleteFavorite(favorite);
    }

    @Override
    public int getSizeFavorite(String userId) {
        return favoriteDao.getSizeFavorite(userId);
    }

    @Override
    public List<FCDetailBo> getListFavorite(FavoriteDto dto) {
        dto.setStart((dto.getPage() - 1) * dto.getPageSize());
        return favoriteDao.getListFavorite(dto);
    }
}
